package org.example;

import org.example.Dao.BookDao;
import org.example.Service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
    public static void main(String[] args) {
        //获取IOC容器
        //参数填写配置文件名称
        ApplicationContext applicationContext =
                new ClassPathXmlApplicationContext("applicationContext.xml");
        //使用spring接口提供的方法，从容器中获取对象
        //getBean方法参数填写bean的id
        //1.获取dao对象
        BookDao bookDao = (BookDao) applicationContext.getBean("bookDao");
        bookDao.save();
        //2.获取service对象
        BookService bookService = (BookService)applicationContext.getBean("bookService");
        bookService.save();

        /*BookService bookService1 = (BookService)applicationContext.getBean("service");
        System.out.println(bookService1);
        BookService bookService2 = (BookService)applicationContext.getBean("service");
        System.out.println(bookService2);*/

    }
}